# https://leetcode-cn.com/problems/water-bottles/
# 1518. 换酒问题

class Solution:
    def numWaterBottles(self, numBottles: int, numExchange: int) -> int:
        result = numBottles
        empty_bottles = numBottles

        while empty_bottles >= numExchange:
            numBottles = empty_bottles // numExchange
            result += numBottles
            empty_bottles = numBottles + empty_bottles % numExchange

        return result


if __name__ == '__main__':
    a = Solution()
    print(a.numWaterBottles(15, 4))
